﻿@using V5_Model;
@{
    var str = Request["s"] + string.Empty;
    if (str == "")
    {
    @("")
    }
    else
    {
        var arryItem = str.Split(',');
        var ItemList = (List<BuyerItem>)Session["BuyerItemList"];
        var ProdModel = new V5_EShop._Class.Model.ModelGZProduct();
        var user = (V5_Model.ModelGZUser)Session["isLogin"];  

        if (ItemList == null)
        {
            ItemList = new List<BuyerItem>();
        }

        foreach (string item in arryItem)
        {
            var t = item.Split(':');
            int Am = int.Parse(t[1]);

            ItemList.Add(new BuyerItem()
            {
                ID = t[0],
                Amount = Am
            });

            ProdModel = new V5_EShop._Class.BLL.BLLGZProduct().GetModel(System.Guid.Parse(t[0].ToUpper()));
            if (ProdModel != null)
            {
                var price = new V5_EShop._Class.BLL.BLLGZProduct().GetPrice(user, ProdModel);
                
                <tr id="si_@(ProdModel.ID)">
                    <td>
                         @{
                            var s = ProdModel.ProductName + string.Empty;
                            if(s.Length>35)        
                            {
                                @(s.Substring(0,35)+"...")
                            }
                            else
                            {
                                @s
                            } 
                        }
                    </td>
                    <td>
                       @price.ToString("0.00")
                    </td>
                    <td>
                        @Am
                    </td>
                    <td>
                         @{
                            System.Data.DataTable tUn = new V5_EShop._Class.BLL.BLLGZUnit().GetList(" id = '" + ProdModel.UnitID+"'").Tables[0];

                            if (tUn != null && tUn.Rows.Count > 0)
                            {
                                @(tUn.Rows[0]["UnitName"]) 
                            }
            
                            }
                    </td>
                    <td>
                        @((price*decimal.Parse(Am.ToString())).ToString("0.00"))
                    </td>
                    <td>
                        <a href="javascript:;" data-id="@(ProdModel.ID)" class="del_sitem">删除</a>
                    </td>
                </tr>
            }

        }
        Session["BuyerItemList"] = ItemList;
    }
}
 